package edu.fzu.crud.utils;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import edu.fzu.crud.bean.vo.StuInfoVo;
import edu.fzu.crud.dao.SchoolMapper;
import edu.fzu.crud.dao.StudentMapper;

/**
 * @author JohnCarraway
 * @create 2021-01-16 22:05
 */
public class StudentExcelListener extends AnalysisEventListener<StuInfoVo> {

    private StudentMapper studentMapper;

    private SchoolMapper schoolMapper;

    public StudentExcelListener() {
    }

    public StudentExcelListener(StudentMapper studentMapper, SchoolMapper schoolMapper) {
        this.studentMapper = studentMapper;
        this.schoolMapper = schoolMapper;
    }

    @Override
    public void invoke(StuInfoVo stuInfoVo, AnalysisContext analysisContext) {

        studentMapper.insertSelectiveByStuInoVo(stuInfoVo);
        schoolMapper.insertSelectiveByStuInfoVo(stuInfoVo);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
